const db=uniCloud.database();
const dbCmd = db.command;
module.exports = {
	_before: function () { // 通用预处理器

	},
	
	async getuserInfo(user_id){
		let res =await db.collection("uni-id-users").doc(user_id).get();
		return res;
	},
	
	async updateuserInfo(obj){
		let{user_id,avatar,nickname,mobile,gander}=obj;
		let res =await db.collection("uni-id-users").doc(user_id).update({
			avatar,nickname,mobile,gander
		});
		return res;
	},
	
	async reduceSurplus(user_id,value){
		let res =await db.collection("uni-id-users").where({
			_id:user_id
		}).update({
			surplus:dbCmd.inc(-value)
		})
		return res;
	},

}
